#include "udp_server.hpp"
#include <cstdlib>
#include <memory>

using namespace std;
using namespace udp;

void usage(const std::string& proc)
{
    std::cout << "Usage:\n\t" << proc << " port\n" << std::endl;
}

std::string echo(std::string request)
{
    return request;
}


// ./udp_server port
int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        usage(argv[0]);
        exit(CMD_ERR);
    }

    uint16_t port = std::stoi(argv[1]);

    unique_ptr<udp_server> usvr(new udp_server(echo, port));
    usvr->init_server();
    usvr->start();

    return 0;
}
